package com.kakarote.oa.common;

import com.kakarote.core.common.enums.SystemCodeEnum;
import com.kakarote.core.exception.CrmException;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 流程标识
 */
public enum ExamineFlagEnum {
    NORMAL(0, "正常"),
    DRAFT(1, "草稿"),
    SUBMITTED(2, "已提交"),
    END(3, "归档"),

    VOID(4, "作废"),

    ;

    private ExamineFlagEnum(Integer type, String remark) {
        this.type = type;
        this.remark = remark;
    }

    private Integer type;
    private String remark;

    public Integer getType() {
        return type;
    }

    public String getRemark() {
        return remark;
    }

    public static ExamineFlagEnum valueOf(Integer type) {
        for (ExamineFlagEnum examineEnum : values()) {
            if (examineEnum.getType().equals(type)) {
                return examineEnum;
            }
        }
        throw new CrmException(SystemCodeEnum.SYSTEM_NO_VALID);
    }

    public static List<Integer> getTypeList() {
        return Arrays.stream(values()).map(ExamineFlagEnum::getType).collect(Collectors.toList());
    }

}
